
function SoloFun_Confirm(pagina,msg){
//alert(pagina);
var truthBeTold = confirm(msg);
	if (truthBeTold) {
           SoloFun_Windows(pagina,200,200,450,350);
	}  
}

function submitpage(page,param)
 {
  document.frmIngreso.opc.value=param;
  document.frmIngreso.action=page;
  document.frmIngreso.submit();
 }
 function submitir3()
 {
  document.frmIngreso.opc.value="C";
  document.frmIngreso.action="soloportal_AdministrarNivel2.php";
  document.frmIngreso.submit();
 }
  function submitir4()
 {
  document.frmIngreso.opc.value="T";
  document.frmIngreso.action="soloportal_AdministrarNivel2.php";
  document.frmIngreso.submit();
 }
   function submitir5()
 {
  document.frmIngreso.opc.value="R";
  document.frmIngreso.action="soloportal_AdministrarNivel3.php";
  document.frmIngreso.submit();
 }

function SoloFun_MostrarFecha(Tipo)
{
	var mydate=new Date();
	var year=mydate.getYear();
	if (year < 1000)
		year+=1900;
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();
	if (daym<10)
		daym="0"+daym;

	var dayarray=new Array("Domingo","Lunes","Martes",acentos("Miércoles"),"Jueves","Viernes",acentos("Sábado"));
	var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");

    switch (Tipo) {
	       case 'Full_1' :document.write(dayarray[day] + ", " + daym + " de " + montharray[month] + " de " + year);
		                   break;
		   case 'Full_2' :document.write(dayarray[day] + " " + daym + ", " + montharray[month] + " " + year);
		                   break;		   
		   case 'Full_3' :document.write("Guayaquil, " + dayarray[day] + " " + daym + " de " + montharray[month] + " de " + year);
		                   break;		   
		   case 'Full_4' :document.write("Ecuador, " + dayarray[day] + " " + daym + " de " + montharray[month] + " de " + year);
		                   break;		   
	}
	return true;
}

function checkKey() {
	var BACKSPACE = 8;
        if(window.event)
            if(window.event.keyCode == BACKSPACE) {
                    window.event.keyCode = 0;
            }

}

function SoloWindows(pagina,t,l,w,h,id) {
	window.open(pagina, 'WinPopup'+id,'width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=1,status=0');
}

function SoloFun_Windows(pagina,t,l,w,h,id) {
	window.open(pagina, 'WinPopup'+id,'width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=1,status=1,menubar=0');
}

function select(field) {
  field.select();
  field.focus();
}

function relocation(path)
{
  location.href=path;
}

function AbrirDialogo(p1)
{
  var pagina='trn_busquedaAlumno.asp?Alumno='+p1;
//alert(pagina)
  showModalDialog(pagina,window,'status:false;dialogwidth:32em;dialogheight:15em');
}

function SoloFun_Submit(forma,tipo)
{   
//alert('tito'+tipo+forma);

//if (tipo==0)
   forma.submit();	
//else
//   if (valida_campos(forma)) 
//      forma.submit();	

}

function valida_campos(form){
  var valido;
  var no_campo;
  var tp_campo;
  
  valido=true;

  for (var e = 0; e < form.elements.length; e++) { // se recorre todos los campos que existan en el formulario
	  no_campo = form.elements[e].name;		       // obtiene el nombre del control.
	  tp_campo = no_campo.substring(0,1);          // obtiene el primer caracter del nombre del control.
	  //tp_camp=tp_camp.toUpperCase();
	  //alert(no_campo + tp_campo + form.elements[e].disabled);
	  if (form.elements[e].disabled==false) { // valida solo los controles que no estan desabilitados
	  switch (tp_campo) {
				 // validacion alfabetica o alfanumerica
				 case 'A' :if (form.elements[e].value.length==0) {
							  valido=false;
						   }break;
				 // validacion alfanumerica
				 case 'X' :if (form.elements[e].value.length==0) {
							  valido=false;
						   }break;						   
				 // validacion numerica
				 case 'N' :if (form.elements[e].value.length==0 || isNaN(form.elements[e].value) || parseFloat(form.elements[e].value) < 0) {
							  valido=false;
						   }break;
				 // validacion numerica para montos
				 case 'M':if (form.elements[e].value.length==0 || parseFloat(form.elements[e].value) < 0) {					   						   
							  valido=false;
						   }break;
	   } // End switch
	   } //end if
	   if (valido==false) {
		  alert("Este Campo es requerido, favor ingrese un valor.");
		  form.elements[e].select();
		  form.elements[e].focus();
		  break;  // break del for
	   }
   }// End for

   return valido;
}// End Function

function tabOnEnter(field, evt)
{

    var keyCode = document.layers ? evt.which : document.all ? evt.keyCode : evt.keyCode;
    var nextfield;
    if (keyCode != 13)
        return true;
    else {
        nextfield = getNextElement(field);
		while (nextfield.disabled == true || nextfield.type == 'hidden') {
			field = nextfield;
        	nextfield = getNextElement(field);
		}
		nextfield.focus();
        return false;
    }
}

function tabOnEnter2(field, evt)
{

    var keyCode = document.layers ? evt.which : document.all ? evt.keyCode : evt.keyCode;
    var nextfield;
    if (keyCode != 13)
        return true;
    else {
        document.form1.submit(); 
        return false;
    }
}


// --------------------------------------------------------------------------------------------------------
//  OBTIENE EL SIGUIENTE ELEMENTO EN UN FORMULARIO
// --------------------------------------------------------------------------------------------------------
function getNextElement(field)
{
    var form = field.form;
    for (var e = 0; e < form.elements.length; e++)
        if (field == form.elements[e])
            break;
        return form.elements[++e % form.elements.length];
}

//----------------------------------------------------------------------------------------------------------------------------------
// Autor:     Mario Velez P.
// Fecha :    28/03/2003
// Parametros: campo --> Es el nombre del control que se desea  bloquear su entrada (su nombre debe empezar con: 'a','n' o 'm')
// Objetivo:  Bloque entrada de datos a solo numeros, solo letras(incluido espacio) o montos (numeros y el punto decimal)
//            dependiendo si el nombre del campo que recibe como parametro empieza con el caracter ('a','m' o'n')
//            Alfabetico, Montos, Numerico. Adem�s permite que la tecla Enter se comporte como la tecla TAB.
//----------------------------------------------------------------------------------------------------------------------------------

function Lock_Field(campo) {
  //var isIE = document.all?true:false;
  var _ret = true;
  no_camp = campo.name;		   		// obtiene el nombre del control.
  tp_camp = no_camp.substring(0,1);  // obtiene el primer caracter del nombre del control.
  tp_camp = tp_camp.toUpperCase();
//  alert(tp_camp);
  //alert(window.event.keyCode)
  // si se pulso ENTER, pasa el focus al siguiente campo (control) 
  // y deja formateado a miles si se trata de un campo de montos
   if ( window.event.keyCode == 13) {  
	   if ( tp_camp == 'M' ) {
		   //campo.value = asMoney(campo.value);
	   }
	   campo = tabOnEnter(campo, event);
   }
   //if ( tp_camp == 'M' ) {
       //alert(campo.value)
	//   campo.value = asMoney(campo.value);
  //} 
  if (campo.disabled==false) {
  switch (tp_camp) {
		 // validacion numerica
		 case 'N' :if (window.event.keyCode < 48 || window.event.keyCode > 57) {   //no setrata de un numero
					   window.event.keyCode = 0;
					  _ret = false;
					}break;
		 case 'T' :if (window.event.keyCode < 48 || window.event.keyCode > 57) {   //no setrata de un numero
					   window.event.keyCode = 0;
					  _ret = false;
					}break;
		 // validacion de campos fecha en formato AA/MM
		 case 'F' :if (window.event.keyCode < 48 || window.event.keyCode > 57) {   //no setrata de un numero
					   window.event.keyCode = 0;
					  _ret = false;
					}break;															
		 // validacion de montos (con el punto decimal)
		 case 'M' :if (window.event.keyCode < 46 || window.event.keyCode == 47  || window.event.keyCode > 57 ) {   //no setrata de un numero o del punto decimal		 
					   window.event.keyCode = 0;
					  _ret = false;					  
					} 
					// validacion para que solo permita digitar una solo vez el punto(.)
	                if (window.event.keyCode == 46 ){ // el punto decimal(.)
					   if (InStr(campo.value,'.')>=0) {
					        window.event.keyCode = 0;
						 }
					}
					break;
		 // validacion de alfab�ticos y la barra espaciadora
		 case 'A' :
//		 alert(window.event.keyCode);
		 if ((window.event.keyCode < 32 || window.event.keyCode > 32 ) && (window.event.keyCode < 65 || window.event.keyCode > 90 ) && (window.event.keyCode < 97 || window.event.keyCode > 122 ) && (window.event.keyCode!= 241) && (window.event.keyCode!=209)  ) {
					   window.event.keyCode = 0;
					  _ret = false;
					}break;
		 // validacion de montos (con el punto decimal)
		/* case 'U' : if (window.event.keyCode < 46 || window.event.keyCode == 47  || window.event.keyCode > 57 ) {   //no setrata de un numero o del punto ecimal
					   window.event.keyCode = 0;
					  _ret = false;
					} break; */
   }// End switch
   //------------------------
   if (tp_camp == 'T') { // numeros de tarjetas separadas de 4 en 4 ejem: 1223-2323-4444-5567
	   if ((campo.value.length==4) || (campo.value.length==9) || (campo.value.length==14) || (campo.value.length==19) || (campo.value.length==24)) {
		  campo.value=campo.value + '-';
	   }   
   }
   //------------------------
   if (tp_camp == 'F') { // fecha en formato AA/MM ejem: 03/12
	   if ((campo.value.length==2) || (campo.value.length==5)) {
		  campo.value=campo.value + '/';         //               99/99/9999
	   } 
   }
   //------------------------   
   /*if (tp_camp == 'U') { // numeros de tarjetas separadas de 4 en 4 ejem: 1223-2323-4444-5567
	   if ((campo.value.length==3) || (campo.value.length==7) || (campo.value.length==11)) {
		  campo.value=campo.value + ',';
	   }   
   }*/
   //------------------------   
   }
   return (_ret); 
}



//---------------------------------------------------------------------------------------------------------
// DESHABILITA EL CLICK DERECHO Y CIERTAS FUNCIONES DE TECLAS
//---------------------------------------------------------------------------------------------------------
function click(event){
//if(event.button==2)
    //alert(' ECUADIGITAL : Derechos Reservados');
}

document.onmousedown=click;
//document.onkeydown = desabilitar; 

function desabilitar() { 
// Teclas de Funciones 
// Teclas 
//alert(window.event.keyCode);
//alert('fin');
//return;
//alert(window.event.keyCode);
switch(window.event.keyCode) { 
        case 17 : // CTRL
		         alert(acentos('esta acción esta restringida'));
				 //event.keyCode = 0; 
				 return false; 
        case 18 : // ALT
		         //alert('presion� ALT');
				 //event.keyCode = 0; 
				 return false; 
        case 27 : // Esc 
				 event.keyCode = 0; 
				 return false; 
        case 112 : // F1 
		         alert('presionó F1');
				 event.keyCode = 0; 
				 return false; 
        case 113 : // F2 
				 event.keyCode = 0; 
				 return false; 
		case 114 : // F3 
				// puede llamar a ejecutar un programa con location.href = "ejemplo.asp"; 
				event.keyCode = 0; 
				return false; 
		case 115 : // F4 
				event.keyCode = 0; 
				return false; 
		case 116 : // F5 
				//event.keyCode = 0; 
				return false; 
		case 117 : // F6 
				event.keyCode = 0; 
				return false; 
		case 118 : // F7 
				event.keyCode = 0; 
				return false; 
		case 119 : // F8 
				event.keyCode = 0; 
				return false; 
		case 120 : // F9 
				event.keyCode = 0; 
				return false; 
		case 121 : // F10 
				event.keyCode = 0; 
				return false; 
		case 122 : // F11 
				event.keyCode = 0; 
				return false; 
		case 123 : // F12 
				//alert('Se Presiono F12');
				event.keyCode = 0; 
				return false; 
		default :
				break; 
} 
}

function acentos(x) {
    // version 040623
            // Spanish - Español
            // Portuguese - Portugués - Português
            // Italian - Italiano
            // French - Francés - Français
            // Also accepts and converts single and double quotation marks, square and angle brackets
            // and miscelaneous symbols.
            // Also accepts and converts html entities for all the above.
    //	if (navigator.appVersion.toLowerCase().indexOf("windows") != -1) {return x}
    x = x.replace(/¡/g,"\xA1");x = x.replace(/&iexcl;/g,"\xA1");
    x = x.replace(/¿/g,"\xBF");x = x.replace(/&iquest;/g,"\xBF");
    x = x.replace(/À/g,"\xC0");x = x.replace(/&Agrave;/g,"\xC0");
    x = x.replace(/à/g,"\xE0");x = x.replace(/&agrave;/g,"\xE0");
    x = x.replace(/Á/g,"\xC1");x = x.replace(/&Aacute;/g,"\xC1");
    x = x.replace(/á/g,"\xE1");x = x.replace(/&aacute;/g,"\xE1");
    x = x.replace(/Â/g,"\xC2");x = x.replace(/&Acirc;/g,"\xC2");
    x = x.replace(/â/g,"\xE2");x = x.replace(/&acirc;/g,"\xE2");
    x = x.replace(/Ã/g,"\xC3");x = x.replace(/&Atilde;/g,"\xC3");
    x = x.replace(/ã/g,"\xE3");x = x.replace(/&atilde;/g,"\xE3");
    x = x.replace(/Ä/g,"\xC4");x = x.replace(/&Auml;/g,"\xC4");
    x = x.replace(/ä/g,"\xE4");x = x.replace(/&auml;/g,"\xE4");
    x = x.replace(/Å/g,"\xC5");x = x.replace(/&Aring;/g,"\xC5");
    x = x.replace(/å/g,"\xE5");x = x.replace(/&aring;/g,"\xE5");
    x = x.replace(/Æ/g,"\xC6");x = x.replace(/&AElig;/g,"\xC6");
    x = x.replace(/æ/g,"\xE6");x = x.replace(/&aelig;/g,"\xE6");
    x = x.replace(/Ç/g,"\xC7");x = x.replace(/&Ccedil;/g,"\xC7");
    x = x.replace(/ç/g,"\xE7");x = x.replace(/&ccedil;/g,"\xE7");
    x = x.replace(/È/g,"\xC8");x = x.replace(/&Egrave;/g,"\xC8");
    x = x.replace(/è/g,"\xE8");x = x.replace(/&egrave;/g,"\xE8");
    x = x.replace(/É/g,"\xC9");x = x.replace(/&Eacute;/g,"\xC9");
    x = x.replace(/é/g,"\xE9");x = x.replace(/&eacute;/g,"\xE9");
    x = x.replace(/Ê/g,"\xCA");x = x.replace(/&Ecirc;/g,"\xCA");
    x = x.replace(/ê/g,"\xEA");x = x.replace(/&ecirc;/g,"\xEA");
    x = x.replace(/Ë/g,"\xCB");x = x.replace(/&Euml;/g,"\xCB");
    x = x.replace(/ë/g,"\xEB");x = x.replace(/&euml;/g,"\xEB");
    x = x.replace(/Ì/g,"\xCC");x = x.replace(/&Igrave;/g,"\xCC");
    x = x.replace(/ì/g,"\xEC");x = x.replace(/&igrave;/g,"\xEC");
    x = x.replace(/Í/g,"\xCD");x = x.replace(/&Iacute;/g,"\xCD");
    x = x.replace(/í/g,"\xED");x = x.replace(/&iacute;/g,"\xED");
    x = x.replace(/Î/g,"\xCE");x = x.replace(/&Icirc;/g,"\xCE");
    x = x.replace(/î/g,"\xEE");x = x.replace(/&icirc;/g,"\xEE");
    x = x.replace(/Ï/g,"\xCF");x = x.replace(/&Iuml;/g,"\xCF");
    x = x.replace(/ï/g,"\xEF");x = x.replace(/&iuml;/g,"\xEF");
    x = x.replace(/Ñ/g,"\xD1");x = x.replace(/&Ntilde;/g,"\xD1");
    x = x.replace(/ñ/g,"\xF1");x = x.replace(/&ntilde;/g,"\xF1");
    x = x.replace(/Ò/g,"\xD2");x = x.replace(/&Ograve;/g,"\xD2");
    x = x.replace(/ò/g,"\xF2");x = x.replace(/&ograve;/g,"\xF2");
    x = x.replace(/Ó/g,"\xD3");x = x.replace(/&Oacute;/g,"\xD3");
    x = x.replace(/ó/g,"\xF3");x = x.replace(/&oacute;/g,"\xF3");
    x = x.replace(/Ô/g,"\xD4");x = x.replace(/&Ocirc;/g,"\xD4");
    x = x.replace(/ô/g,"\xF4");x = x.replace(/&ocirc;/g,"\xF4");
    x = x.replace(/Õ/g,"\xD5");x = x.replace(/&Otilde;/g,"\xD5");
    x = x.replace(/õ/g,"\xF5");x = x.replace(/&otilde;/g,"\xF5");
    x = x.replace(/Ö/g,"\xD6");x = x.replace(/&Ouml;/g,"\xD6");
    x = x.replace(/ö/g,"\xF6");x = x.replace(/&ouml;/g,"\xF6");
    x = x.replace(/Ø/g,"\xD8");x = x.replace(/&Oslash;/g,"\xD8");
    x = x.replace(/ø/g,"\xF8");x = x.replace(/&oslash;/g,"\xF8");
    x = x.replace(/Ù/g,"\xD9");x = x.replace(/&Ugrave;/g,"\xD9");
    x = x.replace(/ù/g,"\xF9");x = x.replace(/&ugrave;/g,"\xF9");
    x = x.replace(/Ú/g,"\xDA");x = x.replace(/&Uacute;/g,"\xDA");
    x = x.replace(/ú/g,"\xFA");x = x.replace(/&uacute;/g,"\xFA");
    x = x.replace(/Û/g,"\xDB");x = x.replace(/&Ucirc;/g,"\xDB");
    x = x.replace(/û/g,"\xFB");x = x.replace(/&ucirc;/g,"\xFB");
    x = x.replace(/Ü/g,"\xDC");x = x.replace(/&Uuml;/g,"\xDC");
    x = x.replace(/ü/g,"\xFC");x = x.replace(/&uuml;/g,"\xFC");
    x = x.replace(/\"/g,"\x22");
    x = x.replace(/\'/g,"\x27");
    x = x.replace(/\</g,"\x3C");
    x = x.replace(/\>/g,"\x3E");
    x = x.replace(/\[/g,"\x5B");
    x = x.replace(/\]/g,"\x5D");
    x = x.replace(/¢/g,"\xA2");x = x.replace(/&cent;/g,"\xA2");
    x = x.replace(/£/g,"\xA3");x = x.replace(/&pound;/g,"\xA3");
    x = x.replace(/€/g,"\u20AC");x = x.replace(/&euro;/g,"\u20AC");
    x = x.replace(/©/g,"\xA9");x = x.replace(/&copy;/g,"\xA9");
    x = x.replace(/®/g,"\xAE");x = x.replace(/&reg;/g,"\xAE");
    x = x.replace(/ª/g,"\xAA");x = x.replace(/&ordf;/g,"\xAA");
    x = x.replace(/º/g,"\xBA");x = x.replace(/&ordm;/g,"\xBA");
    x = x.replace(/°/g,"\xB0");x = x.replace(/&deg;/g,"\xB0");
    x = x.replace(/±/g,"\xB1");x = x.replace(/&plusmn;/g,"\xB1");
    x = x.replace(/×/g,"\xD7");x = x.replace(/&times;/g,"\xD7");
    return x;
}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}